<?php

include _ITSTOCK_INCLUDE_DIR_.'html_search.inc.php';
include _ITSTOCK_INCLUDE_DIR_.'html_message.inc.php';
include _ITSTOCK_INCLUDE_DIR_.'html_navigation.inc.php';
include _ITSTOCK_INCLUDE_DIR_.'html_links.inc.php';
include _ITSTOCK_INCLUDE_DIR_.'html_menu.inc.php';
include _ITSTOCK_INCLUDE_DIR_.'html_table_list.inc.php';
include _ITSTOCK_INCLUDE_DIR_.'settings_html.inc.php';

$itstock_page_info['css'] = array('main.css', 'aside.css', 'float_menu.css', 'page.css', 'table.css', 'lightbox.css', 'form_save.css');
$itstock_page_info['js'] = array('common.js', 'ajax.js', 'request.js', 'lightbox.js', 'search.js', 'settings.js');
$itstock_page_info['title'] = 'Models - IT Stock Tool';
$itstock_page_info['menu_title'] = 'Makers &amp; Models';
$itstock_page_info['menu_items'] = array(
  '<label onclick="itstock_page_request(\'add_model\')">New Model</label>',
  '<label onclick="itstock_page_request(\'add_maker\')">New Maker</label>'
);
$itstock_page_info['search_page'] = 'model';

$_SESSION['on_delete']['model'] = $_SERVER['REQUEST_URI'];
$_SESSION['on_save']['model'] = $_SERVER['REQUEST_URI'];
$_SESSION['on_delete']['maker'] = $_SERVER['REQUEST_URI'];
$_SESSION['on_save']['maker'] = $_SERVER['REQUEST_URI'];

$structure = itstock_html_search_init('model');
$structure['table_headers'] = array('Type', 'Maker', 'Model', '', '');
$structure['table_indexes'] = array('category', 'maker', 'model');
$structure['table_actions'] = array(
  array( 'img' => 'img/edit.png', 'onclick' => 'itstock_page_request(\'add_model\', \'%s\')', 'title' => 'Edit', 'id' => 'id' ),
  array( 'link' => 'delete.php?type=model&id=%s', 'img' => 'img/delete.png', 'title' => 'Delete', 'id' => 'id')
);
$structure['table_error'] = 'No models have been found.';

$cat_get = $_GET;
if(isset($cat_get['idx'])) unset($cat_get['idx']);
if(isset($cat_get['search'])) unset($cat_get['search']);
if(isset($_GET['cat'])) {
  $structure['where'][0] = 'category_id='.itstock_decode($_GET['cat']);
  unset($structure['table_headers'][0]);
  unset($structure['table_indexes'][0]);
}

itstock_html_base_header($itstock_page_info);
echo '<div class="aside">';
itstock_settings_menu();
echo '</div>';
echo '<div class="bside">';
echo '<div style="float:right;">';
itstock_structure($cate, 'category');
$menu_title = array(
  'text' => 'All Hardware',
  'url' => '?page=model'
);
itstock_html_menu_struct($cate, 'category', 'id', 'cat', '', $menu_title, $cat_get);
echo '</div>';
itstock_html_menu_search($itstock_page_info);
echo '<table>';
itstock_html_table_list_data($structure, false, true, true);
echo '</table>';
echo '</div>';
itstock_html_base_footer();
?>
